package lt.mockos.app.client.cpu.event;

import com.google.web.bindery.event.shared.Event;
import com.google.web.bindery.event.shared.EventBus;
import com.google.web.bindery.event.shared.HandlerRegistration;

public class SuperChangeEvent extends Event<SuperChangeEvent.Handler> {

    public interface Handler {

        void onChange(SuperChangeEvent event);
    }

    private static final Type<SuperChangeEvent.Handler> TYPE = new Type<SuperChangeEvent.Handler>();

    public static HandlerRegistration register(EventBus eventBus, SuperChangeEvent.Handler handler) {
        return eventBus.addHandler(TYPE, handler);
    }

    private final String message;

    public SuperChangeEvent(String message) {
        this.message = message;
    }

    @Override
    public Type<SuperChangeEvent.Handler> getAssociatedType() {
        return TYPE;
    }

    public String getMessage() {
        return message;
    }

    @Override
    protected void dispatch(Handler handler) {
        handler.onChange(this);
    }
}
